package me.magicall.poker;

import java.util.Comparator;

import me.magicall.tagInterfaces.HasNameGetter;
import me.magicall.util.kit.Kits;

public enum Num implements HasNameGetter {

	A(1), //
	_2, _3, _4, _5, _6, _7, _8, _9, _10, //
	J(11), Q(12), K(13)//
	;

	public static final Comparator<Num> A_GREATER_COMPARATOR = new Comparator<Num>() {
		@Override
		public int compare(final Num o1, final Num o2) {
			if (o1 == A) {
				return o2 == A ? 0 : 1;
			} else if (o2 == A) {
				return -1;
			}
			return o1.compareTo(o2);
		}
	};

	public final int num;
	public final String name;

	private Num() {
		final String n = name();
		num = Kits.INT.fromString(n.substring(1));
		name = n.length() > 1 ? n.substring(1) : n;
	}

	private Num(final int num) {
		this.num = num;
		final String n = name();
		name = n.length() > 1 ? n.substring(1) : n;
	}

	@Override
	public String getName() {
		return name;
	}

	public int getNum() {
		return num;
	}

}
